﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace RemoteTestRunner.BusinessLogic
{
    internal static class TestAssemblyMetadataFactory
    {
        internal static IAssemblyMetadataRetriever GetAssemblyMetadataRetriever(Contracts.Test test)
        {
            var targetAssembly = Assembly.LoadFrom(test.AssemblyPath);
            AssemblyName[] referencedAssemblies = targetAssembly.GetReferencedAssemblies();

            if (referencedAssemblies.Where(a => a.FullName == "Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a").Count() > 0)
            {
                return new MetadataGrabber2010();
            }

            return new OriginalMetadataGrabber();
        }
    }
}
